
<%= error_messages_for :path %>

<% form_for(:paths, :url => path_path(@path), :html => { :method => :put }) do |form| %>
  <h2>Editing Path:<%= form.text_field :title, :value => @path.title %>
    <a href="#" onclick="javascript:BrowsePath(<%=@path.id%>);">View It!</a>
  </h2>
  <p>Drag page thumbnails to reorder them.</p>
  <div id="path-list-div">
    <%= render :partial=> 'edit_step' %>
  </div>
  <div style="clear:both;"><%= submit_tag 'Save Path' %></div>
<% end %>
<script type="text/javascript">function AddStepToPath()
  {
    var title = $('new_page_title').value;
    var uri = $('new_page_uri').value;    
    var myAjax = new Ajax.Updater('path-list-div', '/paths/add_from_edit?path_id=<%= @path.id %>&uri=' + $('new_page_uri').value + '&title=' + $('new_page_title').value, 
      {asynchronous:true, 
       evalScripts:true
      });
  }
    
  function DeleteStep(id)
  {
    $('list_' + id).remove();
    var myAjax = new Ajax.Request('/paths/update_path_order?path_id=<%= @path.id %>', 
      {asynchronous:true, 
       evalScripts:true, 
       parameters:Sortable.serialize("path-list")
      });
  }
  </script>